package com.example.demo.service.admin;

import com.example.demo.entity.Label;
import com.example.demo.mapper.LabelMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LabelAdminService {

    @Autowired
    private LabelMapper labelMapper;

    /**
     * 查询所有标签
     * @return
     */
    public List<Label> selectAll() {

        return labelMapper.selectAll();
    }

    /**
     * 根据ID查询标签
     * @param id
     * @return
     */
    public Label selectLabelById(Integer id) {
        Label label = labelMapper.selectByPrimaryKey(id);
        return label;
    }

    /**
     * 更新标签
     * @param label
     * @return
     */
    public String updateLabel(Label label) {

        return String.valueOf(labelMapper.updateLabel(label));
    }

    /**
     * 添加标签
     * @param label
     * @return
     */
    public String addLabel(Label label) {

        return String.valueOf(labelMapper.addLabel(label));
    }

    /**
     * 根据ID删除标签
     * @param id
     * @return
     */
    public int deleteLabelById(Integer id) {

        return labelMapper.deleteLabel(id);
    }
}
